<?php
/**
 *
 * @author Strawberry🍓
 * @date 2021-06-02 2:54 下午
 *
 */

namespace app\api\controller;



use app\admin\service\UploadFileService;

class Upload extends Base
{
    public function index()
    {
        $fileName = $this->request->file('file');
        if (empty($fileName)){
            return SendError("请上传图片");
        }
        $savename = \think\facade\Filesystem::disk('public')->putFile( 'topic', $fileName);
        if (empty($savename)){
            return SendError("图片上传失败");
        }
        $data = [
            'showImage' => $this->request->domain().'/uploads/'.$savename,
            'image'     => '/uploads/'.$savename
        ];
        return SendSuccess("success", $data);
    }
}